/*
 * Map.h
 *
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses 
 */

#ifndef MAP_H_
#define MAP_H_

#include <vector>
#include <list>
#include <utility>
#include "MapTile.h"
#include "MapObject.h"
#include "MapEffect.h"

// Clase que modela el mapa

class Map: public Observable {
private:
    int width;
    int height;
    std::vector<MapTile> tiles;
    std::vector<std::pair<int, int> > bomberman_spawns;

public:
    Map(int width, int height);
    int getWidth();
    int getHeight();
    bool isValidPosition(int x, int y);
    // Inserta un objeto en el mapa
    // Notifica OBJECT_ENTERED_MAP si es la primer vez que se inserta
    bool insertObject(MapObject* object, int x, int y);
    // Inserta un drop en el mapa
    // Notifica OBJECT_ENTERED_MAP si es la primer vez que se inserta
    bool dropObject(MapObject* object, int x, int y);
    MapObject* getObject(int x, int y);
    MapObject* getDropedObject(int x, int y);
    MapObject* removeObject(int x, int y);
    bool objectDropedOn(int x, int y);
    MapObject* removeDropedObject(int x, int y);
    void applyEffect(MapEffect* effect, int x, int y);
    void addBombermanSpawn(int x, int y);
    std::vector<std::pair<int, int> >& getBombermanSpawns();
    std::pair<int, int> getRandomBombermanSpawn();
    bool tileIsOccupied(int x, int y);
    ~Map();
private:
    int getIndexFromPos(int x, int y);
};

#endif /* MAP_H_ */
